
--管理器--
ThunderManager = {};
local this = ThunderManager;
canvas = 0;
local score = 0;
local scoreText;
this.PrefabNames={'Player',
                  'Bullet', 
                  'warplane',
                  'warplaneBullet1', 
                  'warplaneBullet2', 
                  'Enemy1',
                  'BossBullet', 
                  'Hp'
                };
this.prefabs={};

function ThunderManager.New()
    resMgr:LoadPrefab("thunder",this.PrefabNames,this.OnLoadPrefab)
    canvas =  GameObject.FindGameObjectWithTag("Canvas").transform;
    scoreText = canvas:Find("ScoreText").gameObject:GetComponent('Text');
end

--加载预制体
--加载游戏对象
function ThunderManager.OnLoadPrefab(objs)
    for i=1,objs.Length do
        table.insert(this.prefabs,objs[i-1])
    end

    --初始化玩家
    Player.new(10,5,4, "Player", this.prefabs[1]);
    
    --初始化敌人
    EnemyFactory.New();
end

function ThunderManager.AddScore(num)
    score = score + num;
    scoreText.text = "当前分数: " .. score;
    print("当前分数" .. score);
end